package com.itqf.vo;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * projectName: SpringMVCTest02
 * @author: 元
 * time: 2021/7/5 0005 20:19
 * description:
 */
public class ResultVO {
    private Integer code=0;
    private String msg="";

    @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
    private Object data;

    public ResultVO() {}

    public ResultVO(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    public static ResultVO OK(String msg, Object data){
        return new ResultVO(1,msg,null);
    }

    public  static ResultVO OK(String msg){

        return new ResultVO(1, msg, null);
    }
    public  static ResultVO OK(Object data){

        return new ResultVO(1, null, data);
    }
/**
     * 失败方法
     * @param msg
     * @param data
     * @return
     */
public  static ResultVO FAIL(String msg, Object data){

    return new ResultVO(0, msg, data);
}
    /**
     * 失败方法
     * @param msg
     * @return
     */
    public  static ResultVO FAIL(String msg){
        return new ResultVO(0, msg, null);
    }
    /**
     * 失败方法
     * @param data
     * @return
     */
    public  static ResultVO FAIL(Object data){
        return new ResultVO(0, null, data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
